package com.tencent.welink.api.space.history;

import com.tencent.welink.api.OpenApiTokenChange;
import com.tencent.welink.api.base.WelinkOpenApi;
import com.tencent.welink.config.BussinessConfig;
import com.tencent.welink.util.CrontabUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Map;

/**
 * @Description: 获取设备原始历史数据
 * @Author: limye
 * @CreateDate: 2020-6-9
 * @Version: V1.0
 */
public class GetDeviceData extends WelinkOpenApi {

    private static final Logger log = LogManager.getLogger(GetDeviceData.class);

    public GetDeviceData(){
        super("/space/datahub/raw-data/getDeviceData",true);
    }


    @Override
    public void displayResult(String result) {
    }


    public static void main(String[] args) {
        new BussinessConfig();
        CrontabUtil.addTaskInRate(new OpenApiTokenChange(), BussinessConfig.loginDurationMinutes,true);

        //实例化对象
        GetDeviceData instance = new GetDeviceData();

        /**
         * 参数名	类型	必填	描述	数据约束
         * din	String	是	要拉取的设备的appId
         * dp	String	是	对应datapoint
         * beginRecordId	String	否	起始记录id，可从返回结果中获取, beginRecordId第一次可以不填
         * endRecordId	String	否	终止记录id
         * limit	int	否	拉取数量限制，最大500
         * token	String	是	鉴权token
         * beginTime	Long	否	开始时间，毫秒时间戳
         * endTime	Long	否	结束时间，毫秒时间戳
         * timeDesc	Boolean	否	true 从最近记录查询 false 从最早记录查询
         * project_id	String	否	项目编号
         */

        //添加参数
        Map<String,Object> map = instance.getExtendsPara();
        map.put("din","300000000000073213");
        map.put("dp","10086");
        map.put("project_id","137");
        map.put("limit","10");
        map.put("timeDesc","true");
       // map.put("wId","a66348f2-0700-1000-abcd-35269c4636aa");

        //执行HTTP请求及展示结果
        instance.DoHttp();
        CrontabUtil.shutdown();

    }
}
